{extend name="../../common/view/admin_base"/}

{block name="main"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">我的资料</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" value="{$curruser.username}" readonly class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">不可修改。一般用于后台登入名</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">真实姓名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="form[truename]" value="{$curruser.truename}" autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别</label>
                            <div class="layui-input-block">
                                <input type="radio" name="form[sex]" value="0" title="男" {if $curruser.sex==0}checked{/if} >
                                <input type="radio" name="form[sex]" value="1" title="女" {if $curruser.sex==1}checked{/if}>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-inline">
                                <input type="text" name="form[password]" value="" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系方式</label>
                            <div class="layui-input-inline" style="width:500px;">
                                <input type="text" name="form[contact]" value="{$curruser.contact}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认</button>
                                <button class="layui-btn layui-btn-primary" lay-submit lay-filter="reset">重置</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['form'],function(){
        var form = layui.form;

        form.on('submit(setmyinfo)', function(obj){
            $.post({
                url:"{:url('admin/index/userinfo')}"
                ,type:'post'
                ,data: obj.field
                ,success:function(res){
                    if(res.code == 1){
                        layer.msg(res.msg, {
                            offset: '15px'
                            ,icon: 1
                            ,time: 1000
                        }, function(){
                            location.href = res.url;
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        });
    });
</script>

{/block}